<?php

class Default_Model_Guests{

	private $guestTbl ;
	
	function __construct(){
		$this->guestTbl = new Default_Model_DbTable_Guests();
	}
	
	public function addGuest($nguoiDaiDien,$chucVu,$toChuc,$diaChi,$dienThoai,$email,$fax,$quocGia){
		$data = array(
			'nguoiDaiDien'	=> $nguoiDaiDien,
			'chucVu'		=> $chucVu,
			'toChuc'		=> $toChuc,
			'diaChi'		=> $diaChi,
			'dienThoai'		=> $dienThoai,
			'email'			=> $email,
			'fax'			=> $fax,
			'quocGia'		=> $quocGia
		);
		$this->guestTbl->insert($data);
	}
	
	public function addCustomGuest($data){
		$this->guestTbl->insert($data);
	}
	
	public function deleteGuest($guestId){
		$this->guestTbl->delete("khachId =".$guestId);
	}
	
	public function fetchCol($colArr,$where=NULL,$order=NULL){
		$sql = "SELECT ";
		for($i =0; $i<count($colArr); $i++){
			if($i != count($colArr)-1)
				$sql .= " ".$colArr[$i]."," ;
			else 
				$sql .= " ".$colArr[$i];
		}
		$sql .=" FROM khach ";
		
		if ($where!=NULL){
			$sql .= " WHERE ".$where;	
		}
		if ($order!=NULL) $sql .=" ORDER BY ".$order;

		return $this->guestTbl->getAdapter()->fetchAll($sql);
	}
	
}

